SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE VIEW [dbo].[VwServiciosAgentesSF]
AS
SELECT        dbo.tb_ServiciosAgentes.idServicioAgente, dbo.tb_ServiciosAgentes.FechaAlta, dbo.tb_ServiciosAgentes.FechaBaja, dbo.tb_ServiciosAgentes.Baja, 
                         dbo.tb_ServiciosAgentes.Horas, dbo.vwrSituacionRevista.Mnemo AS SituacionRevista, dbo.vwrAgentes.Documento, dbo.vwrAgentes.ApellidosYNombres, 
                         dbo.vwrAgentes.ID AS IdAgente, dbo.vwSubServiciosAgentesSF.CUPOF, dbo.vwSubServiciosAgentesSF.idSubServicio, dbo.vwSubServiciosAgentesSF.CUISE, 
                         dbo.vwSubServiciosAgentesSF.IdPlaza, dbo.vwSubServiciosAgentesSF.Organizacion AS IdOrganizacion, dbo.vwrSituacionRevista.ID AS IdSituacionRevista, 
                         dbo.tb_ServiciosAgentes.FechaTermino, dbo.tb_ServiciosAgentes.NroDeOrden9 AS NroDeOrden, 
                         dbo.tb_ServiciosAgentes.EstaEnProcesoDeTitularizacion AS Titularizar, dbo.vwrCargosSalariales.Descripcion AS CargoSalarial, 
                         dbo.vwrAsignaturas.Descripcion AS Asignatura, dbo.vwSubServiciosAgentesSF.SituacionLaboral, dbo.vwSubServiciosAgentesSF.SituacionExtraordinaria, 
                         vwrNormas_4.Descripcion AS NormaAlta, vwrNormas_1.Descripcion AS NormaBaja, dbo.vwSubServiciosAgentesSF.Funcion, dbo.vwSubServiciosAgentesSF.Curso, 
                         dbo.vwSubServiciosAgentesSF.Division, dbo.vwSubServiciosAgentesSF.Turno, dbo.vwSubServiciosAgentesSF.LetraTurno, dbo.vwrCausasAltas.ID AS CausaAlta, 
                         dbo.vwrCausasAltas.Descripcion AS CausaAltaDescripcion, dbo.vwrCausasBajas.ID AS CausaBaja, dbo.vwrCausasBajas.Descripcion AS CausaBajaDescripcion, 
                         dbo.tb_ServiciosAgentes.CargoSalarial AS IdCargoSalarial, dbo.tb_ServiciosAgentes.UbicacionOrig AS UbicacionOriginal, dbo.tb_ServiciosAgentes.TipoDeServicio, 
                         dbo.tb_ServiciosAgentes.RegimenSalarial AS IdRegimenSalarial, dbo.tb_ServiciosAgentes.NormaAltaAnteriores, dbo.tb_ServiciosAgentes.NormaBajaAnteriores, 
                         dbo.tb_ServiciosAgentes.NormaAlta AS IDNormaAltaServicio, dbo.tb_ServiciosAgentes.NormaBaja AS IDNormaBajaServicio, 
                         dbo.vwSubServiciosAgentesSF.FechaAlta AS FechaAltaUltimoSub, dbo.vwSubServiciosAgentesSF.SituacionLaboral AS SitLabUltimoSub
FROM            dbo.tb_ServiciosAgentes LEFT OUTER JOIN
                         dbo.vwrNormas AS vwrNormas_4 ON dbo.tb_ServiciosAgentes.NormaAlta = vwrNormas_4.ID LEFT OUTER JOIN
                         dbo.vwSubServiciosAgentesSF ON dbo.tb_ServiciosAgentes.idServicioAgente = dbo.vwSubServiciosAgentesSF.ServicioAgente LEFT OUTER JOIN
                         dbo.tb_Plazas ON dbo.tb_Plazas.idPlaza = dbo.vwSubServiciosAgentesSF.IdPlaza LEFT OUTER JOIN
                         dbo.vwrAsignaturas ON dbo.tb_Plazas.Asignatura = dbo.vwrAsignaturas.ID LEFT OUTER JOIN
                         dbo.vwrSituacionRevista ON dbo.tb_ServiciosAgentes.SituacionRevista = dbo.vwrSituacionRevista.ID LEFT OUTER JOIN
                         dbo.vwrAgentes ON dbo.tb_ServiciosAgentes.Agente = dbo.vwrAgentes.ID LEFT OUTER JOIN
                         dbo.vwrCargosSalariales ON dbo.tb_ServiciosAgentes.CargoSalarial = dbo.vwrCargosSalariales.ID LEFT OUTER JOIN
                         dbo.vwrCausasBajas ON dbo.tb_ServiciosAgentes.CausaBaja = dbo.vwrCausasBajas.ID LEFT OUTER JOIN
                         dbo.vwrCausasAltas ON dbo.tb_ServiciosAgentes.CausaAlta = dbo.vwrCausasAltas.ID LEFT OUTER JOIN
                         dbo.vwrNormas AS vwrNormas_1 ON dbo.tb_ServiciosAgentes.NormaBaja = vwrNormas_1.ID LEFT OUTER JOIN
                         dbo.tb_Agrupamiento ON dbo.tb_ServiciosAgentes.Agrupamiento = dbo.tb_Agrupamiento.idAgrupamiento
WHERE        (dbo.vwSubServiciosAgentesSF.FechaAlta =
                             (SELECT        MAX(FechaAlta) AS Expr1
                               FROM            dbo.tb_SubserviciosAgentes
                               WHERE        (ServicioAgente = dbo.vwSubServiciosAgentesSF.ServicioAgente)))


GO
GRANT SELECT ON  [dbo].[VwServiciosAgentesSF] TO [CentroDeDesignaciones]
GRANT SELECT ON  [dbo].[VwServiciosAgentesSF] TO [Direcciones De Nivel]
GRANT SELECT ON  [dbo].[VwServiciosAgentesSF] TO [GestionInstitucional]
GRANT SELECT ON  [dbo].[VwServiciosAgentesSF] TO [Juntas]
GRANT SELECT ON  [dbo].[VwServiciosAgentesSF] TO [MCEEjecutivo]
GRANT SELECT ON  [dbo].[VwServiciosAgentesSF] TO [PersonalDocente]
GRANT SELECT ON  [dbo].[VwServiciosAgentesSF] TO [SaludLaboral]
GRANT SELECT ON  [dbo].[VwServiciosAgentesSF] TO [SoloVer]
GRANT SELECT ON  [dbo].[VwServiciosAgentesSF] TO [Subsidios]
GRANT SELECT ON  [dbo].[VwServiciosAgentesSF] TO [SubsidiosConsulta]
GO

EXEC sp_addextendedproperty N'MS_DiagramPane1', N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[41] 4[11] 2[30] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1[50] 2[25] 3) )"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1 [56] 4 [18] 2))"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "tb_ServiciosAgentes"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 114
               Right = 264
            End
            DisplayFlags = 280
            TopColumn = 37
         End
         Begin Table = "vwrNormas_4"
            Begin Extent = 
               Top = 114
               Left = 38
               Bottom = 222
               Right = 227
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "vwSubServiciosAgentesSF"
            Begin Extent = 
               Top = 114
               Left = 265
               Bottom = 222
               Right = 466
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "tb_Plazas"
            Begin Extent = 
               Top = 222
               Left = 38
               Bottom = 330
               Right = 268
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "vwrAsignaturas"
            Begin Extent = 
               Top = 330
               Left = 38
               Bottom = 423
               Right = 227
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "vwrSituacionRevista"
            Begin Extent = 
               Top = 330
               Left = 265
               Bottom = 423
               Right = 454
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "vwrAgentes"
            Begin Extent = 
               Top = 426
               Left = 38
               Bottom = 534
               Righ', 'USER', N'dbo', 'VIEW', N'VwServiciosAgentesSF', NULL, NULL
GO
EXEC sp_addextendedproperty N'MS_DiagramPane2', N't = 227
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "vwrCargosSalariales"
            Begin Extent = 
               Top = 426
               Left = 265
               Bottom = 519
               Right = 454
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "vwrCausasBajas"
            Begin Extent = 
               Top = 522
               Left = 265
               Bottom = 600
               Right = 454
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "vwrCausasAltas"
            Begin Extent = 
               Top = 534
               Left = 38
               Bottom = 627
               Right = 227
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "vwrNormas_1"
            Begin Extent = 
               Top = 600
               Left = 265
               Bottom = 708
               Right = 454
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "tb_Agrupamiento"
            Begin Extent = 
               Top = 6
               Left = 302
               Bottom = 101
               Right = 511
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
', 'USER', N'dbo', 'VIEW', N'VwServiciosAgentesSF', NULL, NULL
GO
DECLARE @xp int
SELECT @xp=2
EXEC sp_addextendedproperty N'MS_DiagramPaneCount', @xp, 'USER', N'dbo', 'VIEW', N'VwServiciosAgentesSF', NULL, NULL
GO
